package com.xmxsuperstar.app.ttac.thread;

import java.util.List;

import android.content.Context;
import android.os.Handler;
import android.widget.ListView;

import com.xmxsuperstar.app.ttac.StatusListAdapter;
import com.xmxsuperstar.app.ttac.collections.FList;
import com.xmxsuperstar.app.ttc.client.TwitterTimeLineClient;
import com.xmxsuperstar.app.ttc.client.model.TwitterStatus;

public class TimeLineRefreshThread extends TimeLineThread {

	public TimeLineRefreshThread(Context context, ListView lv,
			Handler headImageHandler, Handler timeLineHandler,
			TwitterTimeLineClient tc) {
		super(context, lv, headImageHandler, timeLineHandler, tc);
	}

	@Override
	protected void getData() {
		List<TwitterStatus> list = null;
		FList<TwitterStatus> statusList = ((StatusListAdapter) lv.getAdapter())
				.getstatusList();
		if (statusList.size() == 0) {
			list = tc.getTimeLine(20);
		} else {
			long sinceId = statusList.get(0).getId();
			list = tc.getTimeLineBySinceId(sinceId, 20);
		}
		for (int i = list.size() - 1; i >= 0; i--) {
			statusList.add(list.get(i));
		}

	}
}
